package i18n;

import org.junit.Test;

import java.util.Locale;
import java.util.ResourceBundle;

public class LocalTest {

    @Test
    public void test() {
        Locale locale = Locale.getDefault();
        System.out.println(locale);
        Locale[] locale1 = Locale.getAvailableLocales();
        //获取所有
//        for (Locale locale2 : locale1) {
//            System.out.println(locale2  );
//        }
        //获取中文
        Locale locale2 = Locale.CANADA;
        //获取英文
        Locale locale3 = Locale.US;
        System.out.println(locale2);
        System.out.println(locale3);
    }
    @Test
    public void test1(){
        //得到我们需要的Locale对象
        Locale locale = Locale.US;
        ResourceBundle i18 = ResourceBundle.getBundle("abc", locale);
        String username = i18.getString("username");
        String password = i18.getString("password");
        System.out.println(username);
        System.out.println(password);
    }
}
